<!DOCTYPE html>
<html>

<head>

    {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .is_hiddenTr {
            display: none;
        }
         .laydate_box, .laydate_box * {

        box-sizing:content-box;

    }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
<!-- 标题 -->
<div class="page-heade">
    <h2 class="title_color text-center">销售费用核销申请</h2>
</div>
<!-- 标题 -->
<div class="contact-box">
    <a class="btn btn-info" type="button" href="{:url('tihexiao/exportview',['id'=>request()->param('id')])}">导出Excel</a>
</div>
<table class="table table-bordered text-center bud_hei" style="margin-bottom: 0">
    <tr>
        <td style="min-width: 120px;width: 120px">申请人</td>
        <td class="text-left"><span style="color:blue">{$basic.cuser_name}</span></td>
        <td style="min-width: 120px;width: 120px">所属部门/职位</td>
        <td class="text-left">{$basic.cuser_department}/{$basic.cuser_job}</td>
        <td style="min-width: 120px;width: 120px">面单编号</td>
        <td class="text-left">{$basic.sn}</td>
        <td style="min-width: 120px;width: 120px">提交时间</td>
        <td class="text-left">{$basic.ctime}</td>
    </tr>
    <tr>
        <td style="min-width: 120px;width: 120px">经销商名称</td>
        <td class="text-left">{$basic.jxs_title}{if $basic.jxs_direct==1}<span style="color:blue;font-size:12px;">直营</span>{/if}</td>
        <td style="min-width: 120px;width: 120px">开户行</td>
        <td class="text-left">{if $basic.jxs_cw_bank}{$basic.jxs_cw_bank}{else}待补录{/if}</td>
        <td style="min-width: 120px;width: 120px">银行账号</td>
        <td class="text-left" colspan="3">{if $basic.jxs_cw_banksn}{$basic.jxs_cw_banksn}{else}待补录{/if}</td>
    </tr>
</table>
<form action="" method="get" class="form-inline" id="form1">
<table class="table table-striped table-bordered text-center bud_hei">
    <tr class="info">
        <td rowspan="2">序号</td>
        <td rowspan="2">明细编号</td>
        <td rowspan="2">原申请人</td>
        <td rowspan="2">原申请文件</td>
        <td rowspan="2">原申请明细编号</td>
        <td rowspan="2">网点名称</td>
        <td rowspan="2">系统名称</td>
        <td rowspan="2">品牌</td>
        <td rowspan="2">三级费用科目</td>
        <td colspan="3">实际投入</td>
        <td colspan="8">本次申请核销</td>
        <td rowspan="2">支付方式</td>
        <td rowspan="2">本次支付方式</td>
        <td rowspan="2">活动开始日期</td>
        <td rowspan="2">备注</td>
    </tr>
    <tr class="info">
        <td>实际投入金额</td>
        <td>已核销金额</td>
        <td>未核销金额</td>
        <td>未税核销金额</td>
        <td>有无发票</td>
        <td>发票号</td>
        <td>是否增值税(可抵扣)</td>
        <td>税率</td>
        <td>税金</td>
        <td>含税核销金额</td>
        <td>实际投入金额</td>
    </tr>
    {volist name="list" id="row" key="k"}
    <tr>
        <td>{$k}</td>
        <td>
            {if $basic.status==2}
            <a href="javascript:;" class="is_showHide">{$basic.sn}_{$row.tsn}</a>
            {else}
            {$basic.sn}_{$row.tsn}
            {/if}
        </td>
        <td>{$row.ysqr_title}</td>
        <td><a href="{:url('ti_apply2/dataview',['id',$row.t2id])}">{$row.t3sn}</a></td>
        <td>{$row.t3sn}_{$row.t2sn}</td>
        <td>{$row.net_title}</td>
        <td>{$row.system_title}</td>
        <td>{$row.brand_title}</td>
        <td>{$row.feetype_title}</td>
        <td class="text-right">{$row.fb_shijiweishui}</td>
        <td class="text-right">{$row.hx_yihexiao}</td>
        <td class="text-right">{$row.fb_shijiweishui-$row.hx_yihexiao}</td>
        <td class="text-right">{$row.weishuihexiaojine}</td>
        <td>{if $row.youwufapiao==0}无{else}有{/if}</td>
        <td>{$row.fapiaohao}</td>
        <td>{if $row.shizengzhishui}是{else}否{/if}</td>
        <td class="text-right">{$row.shuilv}%</td>
        <td class="text-right">{$row.shuijin}</td>
        <td class="text-right">{$row.hanshuihexiaojine}</td>
        <td class="text-right">{$row.shijitourujine}</td>
        <td>{$row.shijitourujine_title}</td>
        <td> 
        <input type="hidden" name="did[]" value="{$row.tid}"/>
            <select name="paymethod[]" class="form-control">

                        {volist name="pay" id="p"}
                            {if $row.zhifufangshi==$p.id}
                            <option value='{$p.id}' selected>{$p.title}</option>
                            {else/}
                                 <option value='{$p.id}'>{$p.title}</option>
                            {/if}
                        {/volist}
                    </select></td>
        <td>{:date('Y-m-d',$row.huodongkaishiriqi)}</td>
        <td>{$row.beizhu}</td>
    </tr>
    <tr class="is_hiddenTr">
        <td colspan="23" style="padding: 1px 1px 1px 80px">
            <table class="table table-bordered text-center" style="padding: 0;margin:0">
                <tr class="info">
                    <td style="min-width: 40px;width: 40px">编号</td>
                    <td style="min-width: 120px;width: 120px">支付日期</td>
                    <!-- <td class="ObjectNum">355</td> -->
                    <td style="min-width: 120px;width: 120px">支付金额</td>
                    <td style="min-width: 120px;width: 120px">费用凭证号</td>
                    <td style="min-width: 120px;width: 120px">支付类型</td>
                    <td style="min-width: 120px;width: 120px">支付人</td>
                    <td>备注</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2016-02-20</td>
                    <!-- <td class="ObjectNum">355</td> -->
                    <td class="text-right ObjectNum">355</td>
                    <td class="text-left">111</td>
                    <td>支付</td>
                    <td></td>
                    <td>同步货补</td>
                </tr>
                <tr class="trTotal1">
                    <td colspan="2" class="text-right">小计：</td>
                    <td class="text-right ObjectNum">355</td>
                    <td colspan="4"></td>
                </tr>
            </table>
        </td>
    </tr>
    {/volist}
    <tr class="trTotal1 text-right">
        <td colspan="9">合计</td>
        <td class="text-right">{$shijitourujine}</td>
        <td class="text-right">{$yihexiaojine}</td>
        <td class="text-right">{$shijitourujine-$yihexiaojine}</td>
        <td class="text-right">{$weishuihexiaojine}</td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td class="text-right">{$shuijin}</td>
        <td class="text-right">{$hanshuihexiaojine}</td>
        <td class="text-right">{$shijitourujine2}</td>
        <td colspan="4"></td>
    </tr>
    <tr>
        <td colspan="2">备注</td>
        <td colspan="22">{$basic.beizhu}</td>
    </tr>
</table>
<table class="table table-bordered text-left bud_hei">
    <tr class="info">
        <th class="text-left font-bold">审批意见</th>
    </tr>
    <tr>
        <td>华东大区-华东大区经理 <a href="javascript:;">曾小倩</a>审批动作：抄送；审批意见：OK(审批时间：2017-02-20 11:50:23)</td>
    </tr>
    <tr>
        <td>华东大区-华东大区经理 <a href="javascript:;">曾小倩</a>审批动作：抄送；审批意见：无(审批时间：2017-02-20 11:50:34)</td>
    </tr>
</table>

    <table class="table table-bordered text-left bud_hei">
        <tr>
            <th class="text-left info">支付信息</th>
        </tr>
        {volist name="zfxx" id="row"}
        <tr>
            <td>支付凭证：<span>{$row.zfpz}</span> 支付日期：<span>{$row.zfsj}</span> 支付金额：<span>{$row.bczfje}</span>元 支付人：<span>{$row.zfr}</span></td>
        </tr>
        {/volist}
        <tr>
            <td>总含税金额：<span>{$basic.tax}</span>元 已支付金额：<span>{$basic.yzfje}</span>元 未支付金额：<span>{$basic.tax-$basic.yzfje}</span>元 补货及补费中金额：<span>{$basic.bhje}</span>元，可支付金额：{$basic.kzfje}元</td>
        </tr>
        <tr>
            <td>
                <div class="form-group">
                    <label for="" class="form-label">支付凭证<span class="colorRed">*</span>:</label>
                    <input type="text" name="zfpz" class="form-control" style="min-width: 120px;width: 120px">
                </div>
                <div class="form-group" style="margin: 0 10px">
                    <label for="" class="col-xs-4 form-label text-right">支付人<span class="colorRed">*</span>:</label>
                    <div class="col-xs-5">
                        <div class="input-group" id="jxs_input" >
                            <input type="text" placeholder="请输入关键字或空格查询" class="form-control" id="zfr"
                                   name="zfr" value="">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                        <div id="jxs_queding" class="selectedOnlyOne" style="display:none;">
                                <span class="inin"></span>
                                <span class="close">×</span>
                        </div>
                    </div>
                    <div class="col-xs-3">
                        <button class="btn btn-primary" id="select">选择</button>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="form-label">支付时间<span class="colorRed">*</span>:</label>
                    <input type="text" name="zfsj" id="start" class="form-control"
                           style="display: inline-block;min-width: 120px;width: 120px">
                </div>
                <div class="form-group">
                    <label for="" class="form-label">本次支付金额<span class="colorRed">*</span>:</label>
                    <input type="text" name="bczfje" class="form-control" style="min-width: 120px;width: 120px">元
                </div>
                <br>
                <div class="form-group" style="margin:5px 0">
                    <label for="" class="form-label">支付备注：</label>
                    <input type="text" name="zfbz" class="form-control" style="min-width: 240px;width: 240px">
                </div>
            </td>
        </tr>
    </table>
</form>

<!--
<div class="form-group" style="margin:20px 10px 20px 20px">
    <input type="file" id="exampleInputFile">
    <p class="help-block" style="color:#1295d2">注：最多上传15个文件，每个文件小于50M,支持格式：</p>
    <p class="help-block" style="color:#1295d2;">
        jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav</p>
</div>
-->

<div class="row sub_btn white-bg" style="width:100%;text-align:center;padding: 20px 0">
    <input type="submit" class="btn btn-success" value="保存支付凭证" id="save">
    <input type="button" class="btn btn-warning" value="返回" onclick="back()">
</div>

<div class="SuccessImg font-bold">
    已&nbsp;生&nbsp;效
</div>
<!-- 全局js -->
{include file="Public/footer"}
<!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
<script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/common.js"></script>
  <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
  
   <script src="__STATIC__/layout/js/plugins/laydate/laydate.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
	  laydate.render({
       		elem: '#start',
			format: 'yyyy-MM-dd'
       })
    function back() {
        history.go(-1)
    }

    $(document).ready(function () {
        var $ObjectNum = $(".ObjectNum");
        toNum($ObjectNum);

        /*弹出隐藏的tr*/
        $(document).on("click", '.is_showHide', function () {

            var $is_hiddenTr = $(this).parent().parent().next('tr')
            if ($is_hiddenTr.hasClass('is_hiddenTr')) {
                $is_hiddenTr.removeClass('is_hiddenTr')
            } else {
                $is_hiddenTr.addClass('is_hiddenTr')
            }
        })

        $('#save').on('click',function () {
            if(''==$('input[name=zfpz]').val()){
                swal('请输入支付凭证')
                return false
            }
            if(''==$('input[name=zfr]').val()){
                swal('请选择支付人')
                return false
            }
            if(''==$('input[name=zfsj]').val()){
                swal('请选择支付时间');
                return false
            }
            if(''==$('input[name=bczfje]').val()){
                swal('请输入本次支付金额')
                return false
            }
            $.post('',$('#form1').serialize(),function (data) {
               
                if(data.success){
                    swal({title:'保存成功',type:'success'},function () {
                        location.reload();
                    });
                }else{
                    swal(data.msg)
                }
            },'json')
        })

        //支付人搜索自动补全
        $("#zfr").bsSuggest({
            url: '{:url("loadRen")}',
            /*effectiveFields: ["userName", "shortAccount"],
             searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias: {title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            console.log(keyword)
            $('#jxs_queding').find('.inin').html(keyword.key)
            $('#jxs_queding').find('.inin').data('id',keyword.id)
            $('#jxs_queding').show()
            $('#jxs_input').hide()
            $('#jxs_input').find('input').val(keyword.id)
        }).on('onUnsetSelectValue', function () {
            console.log("onUnsetSelectValue");
        });

        //关闭选择
        $('#jxs_queding .close').click(function () {
            $(this).closest('#jxs_queding').hide().find('.inin').html('')
            $('#jxs_input').show().find('input').val('')
        })

        //弹出树
        $('#select').click(function () {
            layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("selectzfr")}'
            })
            return  false
        })
    })
</script>
</body>

</html>
